<template>
  <div class="comment-container">
    <!-- 头像信息等 -->
    <div class="avatar">
      <img v-lazy="item.avatar || defaultAvatar" />
      <div class="user-name">{{ item.name | ellipse }}</div>
    </div>
    <!-- 主体内容 -->
    <div class="content">
      <Star :star="item.star" />
      <!-- 购买的商品sku -->
      <div class="sku"><span v-for="(sku, index) in item.sku" :key="index">{{ sku.name }}：{{ sku.selected }}</span></div>
      <!-- 评价内容 -->
      <div class="comment">{{ item.content }}</div>
      <!-- 图片列表 -->
      <CommentImage :images="item.images" />
      <!-- 评价时间 -->
      <div class="times">{{ item.startTime | time }}</div>
      <!-- 有追评 -->
      <div v-if="item.append">
        <!-- 追评 -->
        <div class="append">
          <span class="prefix">【追评】</span> {{ item.append.content }}
        </div>
        <!-- 评价时间 -->
        <div class="times">{{ item.append.startTime | time }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import Star from '@/components/common/Star'
import CommentImage from './CommentImage'

export default {
  props: {
    item: {
      type: Object,
      default: () => {}
    }
  },

  data () {
    return {
      defaultAvatar: 'http://yanxuan.nosdn.127.net/485ff1be6912be6ae696b6d360d1b101.png'
    }
  },

  components: {
    Star,
    CommentImage
  }
}
</script>

<style lang="less" scoped>
@import "../../styles/variable.less";

.comment-container {
  display: flex;
  padding: 28px 30px;
  .avatar {
    width: 70px;
    img {
      border-radius: 25px;
      display: block;
      width: 50px;
      height: 50px;
      margin: 0 auto;
    }
    .user-name {
      margin-top: 12px;
      width: 100%;
      height: 18px;
      line-height: 18px;
      text-align: center;
    }
  }
  .content {
    flex: 1;
    padding-left: 20px;
    .sku {
      color: @font-color-grey;
      margin-top: 6px;
      span {
        margin-right: 6px;
      }
    }
    .comment {
      font-size: 14px;
      line-height: 20px;
      margin-top: 10px;
      word-break: break-word;
    }
    .times {
      color: @font-color-grey;
      margin-top: 10px;
    }
    .append {
      margin-top: 34px;
      .prefix {
        color: @font-color-golden;
      }
    }
  }
}
</style>
